Declaration of an ARRAY data type in ST
Syntax |
---|
|
Meaning | |
---|---|
Declaration of one or more →array data types (
Use the optional →initial value to assign a value to the array elements. More one possible input for initialization Possible input for array elements of data types (structured data type excepted):
Possible input for array elements with a structured data type or a function block as type:
If you enter more elements within the initialization than there are array elements, Neuron Power Engineer highlights the initialization input as faulty. If you enter fewer elements within the initialization than there are array elements, the remaining array elements are initialized with the initial value of the appropriate data type.
|
See "Accessing the ARRAY data type and ARRAY elements", if you need information about accessing the array elements.
Moreover, Neuron Power Engineer allows you to specify additional data for the declaration. See "Defining description, comment, JSON string or type for variables or data types" for details.
Examples for arrays with one dimension |
---|
|
Examples for multi-dimensional arrays |
---|
|
Using named value as array limits
If you want to use named values for the limits, a data type with named values is required. In order to be able to use a named value, just enter the name as the limit. In order to address the name uniquely, this syntax is provided: data_type_name#named_value
– see the following example
Deviation from IEC-standard The →IEC-standard does not permit the usage of named values. |
Best practice is to use a data type that has been declared with the base data type DINT
. This guarantees that a valid index subrange is specified for the array data type or an array variable. However, if required, you are able to use a data type with named values that has been declared with a base data type belonging to the →generic data type ANY_INT
. Neuron Power Engineer will inform you, if the used values for the index subrange are not within the range of DINT
.
Examples for arrays with one dimension and named values |
---|
|